{% extends 'forum/base/main.html' %}
{% load staticfiles %}

{% block main %}
<div id="board_menu">
    <div id="board_menu_left">
        当前位置: LCForum » <a href="{% url 'board' tboard=board.name %}">{{ board.showname }}</a> » 发文
    </div>
    <div id="board_menu_right">
        <a href="#">返回版面</a>
    </div>
</div>
<form id="post_form" action="" method="post">
    {% csrf_token %}
    <p>
    <input id="post_form_title" type="text" value="{% if father_post %}RE:{{ father_post.title }}{% endif %}{% if origin_post %}{{ origin_post.title }}{% endif %}" name="title" maxlength="254" placeholder="输入文章标题">
    </p>
    <iframe src="{% url 'get_html' filename='upload_input' %}" frameborder="0" id="post_form_upload_iframe"></iframe>
    <input type="hidden" name="uploaded_attachments" id="uploaded_attachments" value="" />
    <div id="post_form_attachments" {% if not origin_post.attachments %}style="display:none;"{% endif %}>
        {% for attachment in origin_post.attachments.all %}
        <div class="post_form_attachment">
            <p><span class="post_form_attachment_label">文件名:</span><span class="post_form_attachment_content" title="{{ attachment.file.name }}">{{ attachment.file.name|truncatechars:16 }}</span></p>
            <p><span class="post_form_attachment_label">大　小:</span><span class="post_form_attachment_content">{{ attachment.file.size|filesizeformat }}</span></p>
            <p class='post_form_attachment_oplink'><a href="#">复制地址</a>|<a href="#">重命名</a>|<a href="#">删除附件</a></p>
        </div>
        {% endfor %}
    </div>
    <p>
    <textarea id="post_form_content" rows="10" name="content" cols="40">{% if father_post %}{{ father_post.content }}{% endif %}{% if origin_post %}{{ origin_post.content }}{% endif %}</textarea>
    </p>
    <p style="text-align: center;">
        <input id="post_form_submit" type="submit" value="提交">
        <input id="post_form_preview_button" type="button" value="预览">
    </p>
</form>
<div id="post_form_preview"> </div>
<script src="{% static 'forum/markdown/markdown.js' %}"></script>
<script>
var post_form_content = $("#post_form_content");
post_form_content.change(function() {
    $("#post_form_preview").html(markdown.toHTML(post_form_content.val()));
    $('code').each(function(i, e) {hljs.highlightBlock(e)});
});
</script>
{% endblock main %}
